package src.twice;

import java.io.*;

public class Student {
    public static void main(String[] args) {
        String content[] = {"明日科技","Java部","快速入门"};
        File file = new File("C:\\Users\\22528\\Desktop","javaTest.txt");
        try {
            FileWriter writer = new FileWriter(file);
            BufferedWriter bufferedWriter = new BufferedWriter(writer);
            for (int i = 0; i < content.length; i++) {
                bufferedWriter.write(content[i]);
                bufferedWriter.newLine();
            }
            bufferedWriter.close();
            writer.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        try {
            FileReader reader = new FileReader(file);
            BufferedReader bufferedReader = new BufferedReader(reader);
            String s = null;
            int i = 0;
            while ((s=bufferedReader.readLine())!=null){
                i++;
                System.out.println("第"+i+"行："+s);
            }
            bufferedReader.close();
            reader.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
